package com.atguigu.sta.controller;


import com.atguigu.sta.service.StatisticsDailyService;
import com.atguigu.utils.R;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author ld
 * @since 2022-08-26
 */
@RestController
@RequestMapping("/staservice/sta")
//@CrossOrigin
@Api(description = "统计数据的管理",value = "统计数据的管理")
public class StatisticsDailyController {

    @Resource
    private StatisticsDailyService statisticsDailyService;
    //获取每天注册的人数
    @GetMapping("/countRegister/{day}")
    public R getCountRegister(@PathVariable("day") String day){
        statisticsDailyService.getCountRegister(day);
        return R.ok();
    }
    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String ,Object> map=statisticsDailyService.getData(type,begin,end);
        return R.ok().data(map);
    }
}

